'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: mcp_example_tool.py
* @Time: 2025/11/21
* @All Rights Reserve By Brtc
'''
from mcp_core.mcp_client import MCPClient
from mcp_core.mcp_protocol import StatusCode


def example_tool():
    with MCPClient(host='127.0.0.1', port=8080) as client:
        print("列出所有工具！")
        response = client.list_tools()
        print("状态码:", response.status_code)
        print("消息:", response.message)
        if response.status_code == StatusCode.SUCCESS.value:
            tools = response.data["tools"]
            print("可用工具数量:", len(tools))
            for tool in tools:
                print("工具列表:", tool)

        print("开始调用工具:")
        print("调用加法工具：")
        response = client.call_tool("add", arguments={"a":10, "b":20})
        print("结果:", response.data["result"])

        print("调用字符串工具")
        response = client.call_tool("to_uppercase", arguments={"text": "hello mcp!"})
        print("结果:", response.data["result"])


        print("调用时间工具")
        response = client.call_tool("get_timestamp")
        print("结果:", response.data["result"])

if __name__ == '__main__':
    example_tool()